package com.chenshuang.web;

import com.chenshuang.bean.Goods;
import com.chenshuang.service.GoodsService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "AllGoodsServlet", value = "/queryAllGoods")
public class AllGoodsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 从数据库中goods表中 查询所有信息 返回给集合
        GoodsService goodsService = new GoodsService();
        List<Goods> list = goodsService.queryAll();

        //把集合上传共享域
        HttpSession session = request.getSession();
        session.setAttribute("listshop",list);
        // 转发 到购物页面
        request.getRequestDispatcher("shopping.jsp").forward(request,response);
    }
}
